﻿using CommonEntity.ShellEntity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ShellAPI.Context
{
    public class ShellContext : DbContext
    {
        public ShellContext(DbContextOptions<ShellContext> options)
           : base(options)
        {

        }

        public DbSet<ShellInfo> ShellInfos { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //初始化数据
            modelBuilder.Entity<ShellInfo>().HasData(new ShellInfo
            {
                ID = 1,
                ShellColor = "黑色",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            },
            new ShellInfo
            {
                ID = 2,
                ShellColor = "白色",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            },
            new ShellInfo
            {
                ID = 3,
                ShellColor = "红色",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            });
        }
    }
}
